package com.mpdbailey.cleverdicandroid;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

public class HintsFragment  extends Fragment
{
	int index = 0;
	TextView indexTextView;
	final static int MAX_INDEX = 10;
	int[] TitleIds = {R.string.tip_title_1,R.string.tip_title_2,R.string.tip_title_3,R.string.tip_title_4,R.string.tip_title_5,R.string.tip_title_6,R.string.tip_title_7,R.string.tip_title_8,R.string.tip_title_9,R.string.tip_title_10};	
	int[] DescriptionIds = {R.string.tip_description_1,R.string.tip_description_2,R.string.tip_description_3,R.string.tip_description_4,R.string.tip_description_5,R.string.tip_description_6,R.string.tip_description_7,R.string.tip_description_8,R.string.tip_description_9,R.string.tip_description_10};
	int[] IndexIds = {R.string.tip_index_1,R.string.tip_index_2,R.string.tip_index_3,R.string.tip_index_4,R.string.tip_index_5,R.string.tip_index_6,R.string.tip_index_7,R.string.tip_index_8,R.string.tip_index_9,R.string.tip_index_10};
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState)
	{
		return inflater.inflate(R.layout.hints_fragment, container, false); 
	}
	

	
	@Override
	public void onActivityCreated(Bundle savedInstanceState)
	{
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		((Button) getActivity().findViewById(R.id.buttonNextTip)).setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				index++;
				if (index>=MAX_INDEX)
				{
					index = 0;
				}
				ShowTip();
			}
		});
		
		ShowTip();
	}
	
	private void ShowTip()
	{
		Activity activity = getActivity();
		String title = activity.getString(TitleIds[index]);
		String description = activity.getString(DescriptionIds[index]);
		String indexStr = activity.getString(IndexIds[index]);
		
		((TextView) getActivity().findViewById(R.id.textTipTitle)).setText(title);
		((TextView) getActivity().findViewById(R.id.textTipDescription)).setText(description);
		((TextView) getActivity().findViewById(R.id.textTipNumber)).setText(indexStr);
		
	}

}
